package com.wnhz.work.jy.activity;

import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.TextView;

import com.wnhz.work.jy.BaseActivity;
import com.wnhz.work.jy.MyApplication;
import com.wnhz.work.jy.R;

/**
 * ---余额
 */
public class SurplusActivity extends BaseActivity implements View.OnClickListener {
    private TextView title;
    private TextView tv_money;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_surplus);

        initView();
        tv_money.setText(MyApplication.getInstance().userBean.getSum());
    }

    private void initView() {
        title = (TextView) findViewById(R.id.view_main_middle_title);
        title.setText("账户余额");
        findViewById(R.id.btn_main_left).setOnClickListener(this);
        findViewById(R.id.rl_extract).setOnClickListener(this);//提现
        findViewById(R.id.rl_top_up).setOnClickListener(this);//充值
        findViewById(R.id.rl_detail).setOnClickListener(this);//收支明细
        tv_money = (TextView) findViewById(R.id.tv_money);
    }

    @Override
    public void onClick(View v) {
        Intent intent;
        switch (v.getId()) {
            case R.id.btn_main_left:
                finish();
                break;

            //提现
            case R.id.rl_extract:
                if ("1".equals(MyApplication.getInstance().userBean.getPayPassword())){
                    startActivity(new Intent(SurplusActivity.this, WithdrawDepositActivity.class));
                }else {
                    showDialogv7(R.string.pay_toast, "取消", "去设置", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            startActivity(new Intent(SurplusActivity.this,PayPasswordActivity.class));
                        }
                    });
                }

                break;

            //充值
            case R.id.rl_top_up:
                if ("1".equals(MyApplication.getInstance().userBean.getPayPassword())){
                    startActivity(new Intent(SurplusActivity.this, TopUpActivity.class));
                }else {
                    showDialogv7(R.string.pay_toast, "取消", "去设置", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            startActivity(new Intent(SurplusActivity.this,PayPasswordActivity.class));
                        }
                    });
                }
                break;

            //收支明细
            case R.id.rl_detail:
                intent = new Intent(SurplusActivity.this, IncomeAndExpensesDetailActivity.class);
                startActivity(intent);
                break;


            default:
                break;
        }
    }
}
